You can not only push the current state of a branch to its remote branch, you can push any commits to any remote branch. This way you can for example push all your commit except the latest with:
git push remotename @~:branchname
I regularly use this when my current commit is not finished yet, but I want to push
the already finished work done in previous commits. How does this work? The
first argument to git push is the remote to which you want to push code (usually
origin
), the second specifies which commit to push to which remote branch. The
@
is short for HEAD
– the current commit, and the ~
selects its parent
commit. You can use @~~
or @~2
if you want to skip the last two commits and
so on. After the colon, you specify the branch name on the target on that you want to push.
en shorterhacks git
Shorter Hacksconsists of tips and tricks for Linux nerds. Flags, hacks, and features of everyday tools that you might not know already, but that will enrich your life. I currently have a list of around 40 hacks I collected and plan to publish them roughly weekly. In order for this series to continue, please send me your best trick(s). The focus is not on fancy new tools or extensive rc-file content, but little known features in software most people already use. Send them to .